/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 *       Filename:  main.c
 *    Description:  Пример использования CRC32 для обнаружения ошибок
 *
 *        Version:  1.0
 *        Created:  10.02.2013 21:33:20
 *         Author:  Aleksey Golovchenko (lexgolovchenko@gmail.com)
 *   Organization:  St.Petersburg State Polytecnical Universisy
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include <stdlib.h>
#include <stdio.h>

#include "crc32.h"
#include "bsc.h"
#include "frame.h"

int trans_num;
double p;
frame_t frame;

int main(int argc, char **argv)
{   
    if (argc < 3) {
        printf("Usage : %s trans_num p \n", argv[0]);
        return EXIT_FAILURE;
    }    
                
    trans_num = atoi(argv[1]);
    p = atof(argv[2]);                 

    srand(time(NULL));

    while (trans_num--) {
        generate_random_frame(&frame);

        bsc(&frame, FRAME_SIZE, p);

        if (!check_frame_crc(&frame)) {
            printf("CRC error! \n");
        }
    }

    return EXIT_SUCCESS;
}
